package calbuilder;

import java.util.Calendar; // for Calendar class

import static java.util.Calendar.*; // for static methods of Calendar c

public class CalendarBuilder {
    public static void main(String args[]) {
        // Old Way
        Calendar calendar =
            Calendar.getInstance(); 
        calendar.set(YEAR, 2013);
        calendar.set(MONTH, OCTOBER);
        calendar.set(DATE, 10);
        calendar.set(HOUR, 3);
        calendar.set(MINUTE, 55);
        calendar.set(SECOND, 45);
        calendar.set(AM_PM, PM);

        System.out.println("Old method: " + calendar.getTime());

        // New Way in jdk8 all set are set as one statement
        Calendar calendar1 =
            new Calendar.Builder()
               .set(YEAR, 2013)
               .set(MONTH, OCTOBER)
               .set(DATE, 10)
               .set(HOUR, 3)
               .set(MINUTE,55)
               .set(SECOND,45)
               .set(AM_PM, PM)
               .build();

        System.out.println("New Method: " + calendar1.getTime());

    }
}
